home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / pcl4c341.zip / DOS.C < prev    next >
Text File  |  1992-12-24  |  2KB  |  77 lines

  1. /* dos.c */
  2.  
  3. #define BYTE unsigned char
  4.  
  5. #include  <stdio.h>
  6. #include  <dos.h>
  7.  
  8. static BYTE cur_row  = 0;      /* current row */
  9. static BYTE cur_col  = 0;      /* current col */
  10.  
  11. /* write character & attribute without advancing cursor */
  12.  
  13. void AttrWrite(ch,attr)
  14. BYTE ch;
  15. BYTE attr;
  16. {union REGS  reg;
  17.  reg.h.ah = 9;
  18.  reg.h.bh = 0;        /* current text page */
  19.  reg.h.al = ch;       /* character */
  20.  reg.h.bl = attr;
  21.  reg.x.cx = 1;
  22.  int86(0x10, ®, ®);
  23. }
  24.  
  25. /* position cursor at desired row & column */
  26.  
  27. void Position(row, col)
  28. BYTE row, col;
  29. {union REGS reg;
  30.  reg.h.ah = 2;
  31.  reg.h.bh = 0;
  32.  reg.h.dh = row;
  33.  reg.h.dl = col;
  34.  int86(0x10, ®, ®);
  35.  cur_row = row;
  36.  cur_col = col;
  37. }
  38.  
  39. /* returns the current row of the cursor */
  40.  
  41. int GetRow()
  42. {union  REGS  reg;
  43.  reg.h.ah = 3;
  44.  reg.h.bh = 0;
  45.  int86(0x10, ®, ®);
  46.  return(reg.h.dh);
  47. }
  48.  
  49. /* returns the current column of the cursor */
  50.  
  51. int GetCol()
  52. {union  REGS  reg;
  53.  reg.h.ah = 3;
  54.  reg.h.bh = 0;
  55.  int86(0x10, ®, ®);
  56.  return(reg.h.dl);
  57. }
  58.  
  59. /* scrolls area specified # rows */
  60.  
  61. void Scroll(urow, lcol, lrow, rcol, nrows, attr)
  62. unsigned  urow;   /* upper row of area */
  63. unsigned  lcol;   /* left column of area */
  64. unsigned  lrow;   /* lower row of area */
  65. unsigned  rcol;   /* right column of area */
  66. int nrows;        /* # rows to scroll */
  67. int attr;         /* attribute to use for blank lines */
  68. {union REGS reg;
  69.  reg.h.ah = 6;
  70.  reg.h.ch = urow;
  71.  reg.h.cl = lcol;
  72.  reg.h.al = nrows;
  73.  reg.h.bh = attr;
  74.  reg.h.dh = lrow;
  75.  reg.h.dl = rcol;
  76.  int86(0x10, ®, ®);
  77. }